<template>
	<view class="content">
		<image src="../../static/image/mineBg.png" class="topBg" mode=""></image>
		<view class="main-title">我的</view>
		<view class="topBox">
			<view class="top">
				<view class="left">
					<view class="name">
						Hello, {{dataInfo.name}}
						<view class="identityBgBox" v-if="dataInfo.role=='discount'">
							<image src="../../static/image/identityBg.png" class="identityBg" mode=""></image>
							<view class="identityCon">
								<image src="../../static/image/hg.png" class="hg" mode=""></image>
								折扣用户
							</view>
						</view>
						<view class="general" v-if="dataInfo.role=='general'">普通用户</view>
					</view>
					<view class="context">
						<view class="conItem" @click="goInfo('/pages-send/balance/balance')">
							<view class="value">{{dataInfo.balance}}</view>
							<view class="key">余额</view>
						</view>
						<view class="conItem" style="margin-left: 98rpx;" @click="goInfo('/pages/order/order')">
							<view class="value">{{dataInfo.express_order_count}}</view>
							<view class="key">订单</view>
						</view>
					</view>
				</view>
				<view class="right">
					<image :src="dataInfo.avatar?dataInfo.avatar:'../../static/image/0.png'" class="head" mode=""></image>
					<!-- <view class="headEdit"> -->
						<!-- <u-icon name="edit-pen-fill" color="#fff" size="26"></u-icon> -->
					<!-- </view> -->
				</view>
			</view>
			<view class="bottom" v-if="dataInfo.role=='discount'">
				<image src="../../static/image/zkyhbg.png" mode="" class="bgImg"></image>
				<view class="boBox">
					<view class="left">
						<image src="../../static/image/zkyh.png" class="zk" mode=""></image>
						<view class="text">折扣用户享受购买商品寄快递等折扣</view>
					</view>
					<view class="right">查看详情</view>
				</view>	
			</view>
			<view class="bottom" v-if="dataInfo.role=='general'">
				<image src="../../static/image/ptbg.png" mode="" class="bgImg"></image>
				<view class="boBox">
					<view class="left">
						<image src="../../static/image/ptyh.png" class="zk" mode=""></image>
						<view class="text" style="color:rgba(255,255,255,.6)">普通用户不享受购买商品寄快递等折扣</view>
					</view>
					<view class="right">查看详情</view>
				</view>	
				
			</view>
		</view>
		<view  class="conBox">
			<view class="title">常用功能</view>
			<view class="navBox">
				<view v-for="(item,index) in commonFunctions" style="width: 25%;">
					<view v-if="item.type=='link'" class="navItem" @click="goInfos(item)">
						<image :src="imgUrl+item.icon" class="icon" mode=""></image>
						<view class="text">{{item.name}}</view>
					</view>
				</view>
				
				<!-- <view class="navItem" @click="goInfo('/pages-send/expressList/expressList')">
					<image src="../../static/image/kdlb.png" class="icon" mode=""></image>
					<view class="text">快递列表</view>
				</view>
				<view class="navItem" @click="goInfo('/pages-send/myAddress/myAddress')">
					<image src="../../static/image/wddz.png" class="icon" mode=""></image>
					<view class="text">我的地址</view>
				</view>
				<view class="navItem" @click="phoneShow=true;getSettingInfo()">
					<image src="../../static/image/lxwm.png" class="icon" mode=""></image>
					<view class="text">联系我们</view>
				</view> -->
			</view>
			<view class="title">注意事项</view>
			<view class="navBox">
				<view v-for="(item,index) in attentionList"  style="width: 25%;">
					<view v-if="item.type=='link'" class="navItem" @click="goInfos(item)">
						<image :src="imgUrl+item.icon" class="icon" mode=""></image>
						<view class="text">{{item.name}}</view>
					</view>
				</view>
				<!-- <view class="navItem" @click="goInfo('/pages-send/helpCenter/helpCenter')">
					<image src="../../static/image/bzzx.png" class="icon" mode=""></image>
					<view class="text">帮助中心</view>
				</view>
				<view class="navItem" @click="goInfo('/pages-send/contraband/contraband')">
					<image src="../../static/image/wjp.png" class="icon" mode=""></image>
					<view class="text">违禁品列表</view>
				</view>
				<view class="navItem" @click="goInfo('/pages-send/packing/packing')">
					<image src="../../static/image/bzf.png" class="icon" mode=""></image>
					<view class="text">包装费列表</view>
				</view> -->
				
			</view>
		</view>
		
		<!-- 客服电话 -->
		<u-popup v-model="phoneShow" mode="center" :custom-style="{background:'rgba(0,0,0,0)'}">
			<view class="phoneBox">
				<image src="../../static/image/phoneBg.png" class="phoneBg" mode=""></image>
				<view class="boxs">
					<view class="titles">联系我们</view>
					<view class="line"></view>
					<view class="sub-title">客服电话</view>
					<view class="phone">{{phone}}</view>
					<view class="btn" @click="callBtn(phone)">一键拨打</view>
				</view>
			</view>
		</u-popup>
		
		<!-- 导航栏 -->
		<tabbar link="/pages/mine/mine"></tabbar>
	</view>
</template>

<script>
	import tabbar from '../../components/tabbar/tabbar.vue'
	import {userInfo,getSettingInfo} from '../../common/api.js'
	import request from '../../common/common.js'
	export default {
		components:{tabbar},
		data() {
			return {
				imgUrl:request.imgUrl,
				phoneShow:false,
				phone:'',
				dataInfo:{},
				attentionList:[],
				commonFunctions:[],
			}
		},
		onShow() {
			this.getUserInfo()
			this.getSettingInfo()
		},
		methods: {
			getSettingInfo(){
				getSettingInfo('usPhone,commonFunctions,attentionList',{}).then(res=>{
					console.log(res)
					if(res.code==10000){
						this.phone=res.data.usPhone
						this.attentionList=JSON.parse(res.data.attentionList)
						this.commonFunctions=JSON.parse(res.data.commonFunctions)
					}
				})
			},
			getUserInfo(){
				userInfo({}).then(res=>{
					console.log(res)
					if(res.code==10000){
						this.dataInfo = res.data
					}
				})
			},
			goInfo(url){
				if(!url){
					uni.showToast({
						title: '开发中...',
						duration: 2000,
						icon:"none"
					});
					return
				}
				if(url=='usPhone'){
					this.phoneShow=true;
					this.getSettingInfo()
					return
				}
				if(url=='/pages/order/order'){
					uni.reLaunch({
						url:url
					});
				}else{
					uni.navigateTo({
						url:url
					})
				}
				
			},
			goInfos(item){
				if(item.url=='usPhone'){
					this.phoneShow=true;
					this.getSettingInfo()
					return
				}
				if(item.type=='link'){
					if(!item.url){
						uni.showToast({
							title: '开发中...',
							duration: 2000,
							icon:"none"
						});
						return
					}
					uni.navigateTo({
						url:item.url
					})
					return
				}else if(item.type=='url'){
					if(!item.url){
						uni.showToast({
							title: '开发中...',
							duration: 2000,
							icon:"none"
						});
						return
					}
					window.location.href=item.url
				}else if(item.type=='mini'){
					console.log('小程序')
				}
			},
			callBtn(phone){
				uni.makePhoneCall({
					phoneNumber: phone //仅为示例
				});
			}
		}
	}
</script>

<style scoped lang="scss">
.content{
	width: 750rpx;
	position:relative;
	.main-title{
		width: 100%;
		height: 120rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 600;
		font-size: 34rpx;
		color: #333333;
		line-height: 120rpx;
		text-align: center;
		font-style: normal;
		position: absolute;
		left: 0;
		top: 0;
	}
	.topBg{
		width: 750rpx;
		height: 723rpx;
		background-color: #EDEFF2;
	}
	.topBox{
		width: 750rpx;
		height: 723rpx;
		position: absolute;
		left: 0;
		top: 0;
		padding: 0 43rpx;
		
		.top{
			display: flex;
			justify-content: space-between;
		}
		.left{
			.name{
				font-family: DINAlternate, DINAlternate;
				font-weight: bold;
				font-size: 40rpx;
				color: #333333;
				line-height: 38rpx;
				text-align: left;
				font-style: normal;
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				margin-top: 237rpx;
				
				.general{
					width: 124rpx;
					height: 40rpx;
					background: #979A99;
					border-radius: 0rpx 20rpx 20rpx 20rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 20rpx;
					color: #FFFFFF;
					line-height: 40rpx;
					text-align: center;
					font-style: normal;
					margin-left: 16rpx;
				}
				.identityBgBox{
					width: 124rpx;
					height: 40rpx;
					margin-left: 16rpx;
					position: relative;
					.identityBg{
						width: 124rpx;
						height: 40rpx;
					}
					.identityCon{
						width: 124rpx;
						height: 40rpx;
						position: absolute;
						left: 0;
						top:0;
						.hg{
							width: 18rpx;
							height: 12rpx;
							margin-right: 5rpx;
						}
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						font-size: 20rpx;
						color: #FFFFFF;
						line-height: 40rpx;
						text-align: center;
						font-style: normal;
					}
				}
			}
			.context{
				display: flex;
				align-items: center;
				flex-wrap: nowrap;
				margin-top: 76rpx;
				.conItem{
					width: 147rpx;
					.value{
						font-family: DINAlternate, DINAlternate;
						font-weight: bold;
						font-size: 50rpx;
						color: #1AA261;
						line-height: 50rpx;
						text-align: center;
						font-style: normal;
					}
					.key{
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #333333;
						line-height: 33rpx;
						text-align: center;
						font-style: normal;
						margin-top: 13rpx;
					}
				}
			}
		}
		.right{
			width: 170rpx;
			height: 170rpx;
			margin-top: 207rpx;
			position: relative;
			.head{
				width: 170rpx;
				height: 170rpx;
				border-radius: 50%;
			}
			.headEdit{
				width: 48rpx;
				height: 48rpx;
				background: #1AA261;
				border: 5rpx solid #EDEFF2;
				text-align: center;
				line-height: 48rpx;
				border-radius: 50%;
				position: absolute;
				right: 0;
				bottom: 0;
			}
		}
		.bottom{
			width: 100%;
			// height: 270rpx;
			
			margin-top: 135rpx;
			position: relative;
			.bgImg{
				width: 100%;
				height: 140rpx;
				position: absolute;
				top: 0;
				left:0;
			}
			.boBox{
				width: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;
				// background: #161B39;
				border-radius: 30rpx 30rpx 0 0 ;
				padding: 30rpx 40rpx;
				position: absolute;
				top: 0;
				left:0;
				.left{
					.zk{
						width: 155rpx;
						height: 38rpx;
					}
					.text{
						margin-top: 15rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 20rpx;
						color: #F0C983;
						line-height: 20rpx;
						text-align: left;
						font-style: normal;
					}
				}
				.right{
					width: 168rpx;
					height: 64rpx;
					background: #1AA261;
					border-radius: 35rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #FFFFFF;
					line-height: 64rpx;
					text-align: center;
					font-style: normal;
					margin: 0;
					
				}
			}
			
		}
	}

	.conBox{
		padding:0 40rpx;
		padding-bottom: 200rpx;
		box-sizing: border-box;
		// background: #fff;
		.title{
			font-family: PingFangSC, PingFang SC;
			font-weight: 600;
			font-size: 38rpx;
			color: #333333;
			line-height: 38rpx;
			text-align: left;
			font-style: normal;
			margin-top: 80rpx;
		}
		.title:after{
			content: " ";
			display: block;
			width: 144rpx;
			height: 9rpx;
			background: rgba(26,162,97,0.33);
			border-radius: 5rpx;
			margin-left: 5rpx;
		}
		.navBox{
			display: flex;
			// justify-content: space-around;
			flex-wrap: nowrap;
			margin-top: 60rpx;
			.navItem{
				width: 100%;
				// margin-left: 56rpx;
				.icon{
					width: 40rpx;
					height: 40rpx;
					margin-left: 50%;
					transform: translateX(-50%);
				}
				.text{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #333333;
					line-height: 24rpx;
					text-align: center;
					font-style: normal;
					margin-top: 24rpx;
				}
			}
		}
	}

	.phoneBox{
		width: 539rpx;
		height: 634rpx;
		.phoneBg{
			width: 100%;
			height: 100%;
		}
		.boxs{
			width: 100%;
			height: 100%;
			position: absolute;
			left: 0;
			top: 0;
			padding: 0 40rpx;
			box-sizing: border-box;
			.titles{
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #333333;
				line-height: 32rpx;
				text-align: left;
				font-style: normal;
				margin-top: 143rpx;
			}
			.line{
				width: 71rpx;
				height: 9rpx;
				background: #1AA261;
				border-radius: 9rpx;
				margin-top: 32rpx;
			}
			.sub-title,.phone{
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #666666;
				line-height: 58rpx;
				text-align: center;
				font-style: normal;
			}
			.sub-title{
				margin-top: 51rpx;
			}
			.phone{
				color: #333;
				font-weight: 600;
			}
			.btn{
				width: 100%;
				height: 88rpx;
				background: #1AA261;
				border-radius: 44rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 30rpx;
				color: #FFFFFF;
				line-height: 88rpx;
				text-align: center;
				font-style: normal;
				margin-top: 89rpx;
			}
		}
	}
}
</style>
